package com.dingreading.cloud.subject.controller;

import com.dingreading.cloud.common.base.R;
import com.dingreading.cloud.subject.service.CourseTrainCommonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


@RestController
@RequestMapping(value = "/front/courseTrain")
@Api(tags = "门店-新人培训管理")
public class FrontCourseTrainController {
    @Resource
    private CourseTrainCommonService courseTrainCommonService;

    @ApiOperation(value = "获取所有列表信息")
    @PostMapping(value = "/getList", produces = "application/json; charset=UTF-8")
    public R<Object> getList(
            @ApiParam(value = "公司uid") @RequestParam(value = "corpUid") String corpUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "门店名称") @RequestParam(value = "storeName") String storeName,
            @ApiParam(value = "员工uid") @RequestParam(value = "staffUid") String staffUid,
            @ApiParam(value = "员工姓名") @RequestParam(value = "staffName") String staffName
    ) {
        return courseTrainCommonService.getList(corpUid, storeUid, storeName, staffUid, staffName);
    }


    @ApiOperation(value = "获取培训课程信息")
    @PostMapping(value = "/getCourseTrain", produces = "application/json; charset=UTF-8")
    public R<Object> getCourseTrain(
            @ApiParam(value = "公司uid") @RequestParam(value = "corpUid") String corpUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "门店名称") @RequestParam(value = "storeName") String storeName,
            @ApiParam(value = "员工uid") @RequestParam(value = "staffUid") String staffUid,
            @ApiParam(value = "员工姓名") @RequestParam(value = "staffName") String staffName,
            @ApiParam(value = "课程Uid") @RequestParam(value = "uid") String uid
    ) {
        return courseTrainCommonService.getCourseTrain(corpUid, storeUid, storeName, staffUid, staffName, uid);
    }

    @ApiOperation(value = "获取考试文件的地址")
    @PostMapping(value = "/getExamUrl", produces = "application/json; charset=UTF-8")
    public R<Object> getExamUrl(
            HttpServletRequest request,
            @ApiParam(value = "公司uid") @RequestParam(value = "corpUid") String corpUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "门店名称") @RequestParam(value = "storeName") String storeName,
            @ApiParam(value = "员工uid") @RequestParam(value = "staffUid") String staffUid,
            @ApiParam(value = "员工姓名") @RequestParam(value = "staffName") String staffName,
            @ApiParam(value = "分类uid") @RequestParam(value = "typUid") String typUid
    ) {
        return courseTrainCommonService.getExamUrl(request, corpUid, storeUid, storeName, staffUid, staffName, typUid);
    }

    @ApiOperation(value = "获取课程文件的观看地址")
    @PostMapping(value = "/getFileUrl", produces = "application/json; charset=UTF-8")
    public R<Object> getFileUrl(
            HttpServletRequest request,
            @ApiParam(value = "公司uid") @RequestParam(value = "corpUid") String corpUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "门店名称") @RequestParam(value = "storeName") String storeName,
            @ApiParam(value = "员工uid") @RequestParam(value = "staffUid") String staffUid,
            @ApiParam(value = "员工姓名") @RequestParam(value = "staffName") String staffName,
            @ApiParam(value = "课程Uid") @RequestParam(value = "uid") String uid,
            @ApiParam(value = "文件Uid") @RequestParam(value = "fileUid") String fileUid
    ) {
        return courseTrainCommonService.getFileUrl(request, corpUid, storeUid, storeName, staffUid, staffName, uid, fileUid);
    }

    @ApiOperation(value = "添加视频访问记录")
    @PostMapping(value = "/addVideoLog", produces = "application/json; charset=UTF-8")
    public R<Object> addVideoLog(
            HttpServletRequest request,
            @ApiParam(value = "公司uid") @RequestParam(value = "corpUid") String corpUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "门店名称") @RequestParam(value = "storeName") String storeName,
            @ApiParam(value = "员工uid") @RequestParam(value = "staffUid") String staffUid,
            @ApiParam(value = "员工姓名") @RequestParam(value = "staffName") String staffName,
            @ApiParam(value = "课程Uid") @RequestParam(value = "uid") String uid,
            @ApiParam(value = "文件Uid") @RequestParam(value = "fileUid") String fileUid,
            @ApiParam(value = "时间戳") @RequestParam(value = "timeStamp") String timeStamp,
            @ApiParam(value = "开始时间/秒") @RequestParam(value = "startTime") Integer startTime,
            @ApiParam(value = "结束时间/秒") @RequestParam(value = "endTime") Integer endTime
    ) {
        return courseTrainCommonService.addVideoLog(
                request, corpUid, storeUid, storeName, staffUid, staffName, uid, fileUid, timeStamp, startTime, endTime
        );
    }

}
